package com.imooc.zhangxiaoxi.guava;

import com.google.common.base.Charsets;
import com.google.common.io.CharSink;
import com.google.common.io.CharSource;
import com.google.common.io.Files;

import java.io.File;
import java.io.IOException;

/**
 * @Description :
 * @Author : YTY
 * @Date : 2021-01-20 18:39
 */
public class IOUtils {

    public static void simpleCopyFile(String sourceName, String sinkName) {

        /**
         * 创建对应的Source和Sink
         */
        CharSource charSource = Files.asCharSource(
                new File(sourceName),
                Charsets.UTF_8
        );
        CharSink charSink = Files.asCharSink(
                new File(sinkName),
                Charsets.UTF_8
        );

        /**
         * 拷贝
         */
        try {
            charSource.copyTo(charSink);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
